class StartScreen:ScriptObject
{
}

class KopterButton:ScriptObject
{
	float timer;
	
	int state;
	
	
	void init()
	{
		timer=2;
		state=0;
	}
	
	void update()
	{
		switch (state)
		{
			case 0:
			{
				set_guitexture_color(entity,float4(1,1,1,0));
				if (timer>0)
				{
					timer-=1/60.0;
					break;
				}
				
				timer=0;
				state=1;
			}
			case 1:
			{
				if (bird_small_button_down() || bird_big_button_down())
				{
					load_scene("scenes/game");
				}
				timer+=1/60.0f;
				float a=1-(cos(timer*3)+1)/2;
				float4 c(1,1,1,a);
				set_guitexture_color(entity,c);
				break;
			}
		}
	}
}

class FadeOut:ScriptObject
{
	float timer;
	
	void init()
	{
		timer=8;
	}
	
	void update()
	{
		timer-=1.0f/60.0f;
		
		if (timer<=0)
		{
			load_scene("scenes/endscreen");
			return;
		}
		
		if (timer<3)
		{
			set_guitexture_color(entity,float4(0,0,0,1-timer/3));
		}
	}
}

class EndTestek:ScriptObject
{
	int boxnum;
	int maxboxnum;
	int state;
	float timer;
	void init()
	{
		boxnum=0;
		state=0;
		maxboxnum=22-total_boxes;
		if (maxboxnum>20)
			maxboxnum=20;
		
		set_guitexture_scale(entity,0,1);
		
		timer=0.3f;
	}
	
	void update()
	{
		switch (state)
		{
			case 0:
			{
				if (boxnum==maxboxnum)
				{
					state=1;
					break;
				}
				
				timer-=1/60.0f;
				
				if (timer<=0)
				{
					boxnum++;
					
					set_guitexture_scale(entity,float(boxnum)/float(maxboxnum),1);
					timer=0.3f;
				}
				
			}
			case 1:
			{
				if (bird_small_button_down() || bird_big_button_down())
				{
					end_game();
				}
				break;
			}
		}
	}
}